package databases

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/mattn/go-sqlite3"
)

type Sqlite3DB struct {
}

func (sqlite3 Sqlite3DB) Connect_db() {
	beego.LoadAppConfig("ini", "application/conf/database.conf")
	//orm.Debug = true
	//读取配置信息
	maxIdle, _ := beego.AppConfig.Int("db_" + beego.AppConfig.String("db_type") + "_idle")
	maxConn, _ := beego.AppConfig.Int("db_" + beego.AppConfig.String("db_type") + "_conn")

	//sqlite3数据库
	orm.RegisterDataBase(
		beego.AppConfig.String("db_alias"),
		beego.AppConfig.String("db_type"),
		"file:"+beego.AppConfig.String("db_"+beego.AppConfig.String("db_type")+"_file"),
		maxIdle,
		maxConn,
	)
}
